<style>
    body {
        background-color: #ffffff;
    }

    .xm-select-size {
        width: 200px;
        float: left;
    }
</style>
<div class="layui-form layuimini-form">
    <div class="layui-form-item">
        <label class="layui-form-label required">观剧厅</label>
        <div class="layui-input-block">
            <input type="text" name="title" lay-verify="required" lay-reqtext="观剧不能为空" placeholder="请输入观剧标题"
                   value="{$edit.title}"
                   class="layui-input">
            <tip></tip>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">选择剧场</label>
        <div class="layui-input-block">
            <div id="venue" class="xm-select-size"></div>
            <div id="theatre_cate" class="xm-select-size"></div>
        </div>
    </div>
    <div class="layui-form-item">
        <label class="layui-form-label required">选择剧院</label>
        <div class="layui-input-block">
            <select name="type" id="type">
                <option value="">选择剧场</option>
                <option value="1" {if condition="$edit.type eq 1"}selected{/if}>金科旗舰店剧场</option>
                <option value="2" {if condition="$edit.type eq 2"}selected{/if}>沙磁巷小剧场</option>
                <option value="3" {if condition="$edit.type eq 3"}selected{/if}>沙磁巷新剧场</option>
                <option value="4" {if condition="$edit.type eq 4"}selected{/if}>扯馆儿渝中区品牌形象店</option>
                <option value="4" {if condition="$edit.type eq 5"}selected{/if}>嘎嘎酒剧场</option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-block">
            <input type="hidden" name="id" value="{$edit.id}">
            <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/extends/ueditor/ueditor.config.js"></script>
<script type="text/javascript" src="/static/extends/ueditor/ueditor.all.js"></script>
<script type="text/javascript">
    layui.config({
        base: '/static/extends/'
    }).extend({
        xmSelect: 'xmSelect/xm-select'
    });
    layui.use(['form', 'xmSelect', "upload", "element", 'laydate'], function () {
        var form = layui.form,
            layer = layui.layer,
            $ = layui.$,
            xmSelect = layui.xmSelect,
            upload = layui.upload,
            element = layui.element,
            laydate = layui.laydate;


        let venue = xmSelect.render({
            el: '#venue',
            filterable: true,
            searchTips: '请选择剧院',
            tips: '请选择剧院',
            radio: true,
            clickClose: true,
            data: [],
            paging: true,
            pageSize: 10,
            name: 'venue',
            initValue:[
                {$edit.venue}
            ],
            on: function (res) {
                let data = res.change[0];
                hadmin.http("{:url('theatreCate/getTheatreCateByList')}", {
                    venueId: data.value
                }).then(res => {
                    if (res.code == 1) {
                        theatre_cate.update({
                            data: res.data
                        })
                    }
                })
            }
        });
        hadmin.http("{:url('theatreCate/getTheatreCateByList')}", {
            venueId: {$edit.venue}
        }).then(res => {
            if (res.code == 1) {
                theatre_cate.update({
                    data: res.data,
                    initValue: [{$edit.theatre_cate_id}]
                })
            }
        })
        let theatre_cate = xmSelect.render({
            el: '#theatre_cate',
            filterable: true,
            searchTips: '请选择剧场',
            tips: '请选择剧场',
            radio: true,
            clickClose: true,
            data: [],
            paging: true,
            pageSize: 10,
            name: 'theatre_cate_id',
            on: function (res) {
                let data = res.change[0];
                hadmin.http("{:url('seat/getSeatByList')}", {
                    cate_id: data.value
                }).then(res => {
                    seat.update({
                        data: res.data
                    })
                })

            }
        });
        //监听提交
        form.on('submit(saveBtn)', function (data) {
            hadmin.http("{:url('save')}", data.field).then(res => {
                if (res.code == "{$result.normal}") {
                    hadmin.father_reload();
                }
            })

            return false;
        });

        hadmin.http("{:url('venue/getVenueByList')}").then(res => {
            venue.update({
                data: res.data
            })
        })
    });
</script>
</body>
</html>
